mid and final project for REST-API course - #1
Open
davidspythonjourney wants to merge 1 commit into
Open
Conversation
ngothait1
reviewed
Nov 18, 2024
| app = Flask(__name__) | ||
| #change for pr | ||
| JSON_NUM = 0 | ||
| tasks = {} |
Collaborator
There was a problem hiding this comment.
why is JSON_NUM capital and tasks small? be consistent (no need to re-submit)
| def completeTask(task_id): | ||
| global tasks | ||
| if task_id in tasks: | ||
| tasks[task_id]["message"] = "Task marked as completed" |
Collaborator
There was a problem hiding this comment.
i dont quite understand the stucture of a task in your code. it has a title AND a message field? or the message is only for the REST response?
| if not data or "title" not in data or "description" not in data: | ||
| return jsonify({"error": "Bad Request, data must include 'title' and 'description' "}), 400 | ||
| JSON_NUM += 1 | ||
| new_task = {str(JSON_NUM): { |
| def updateTask(task_id): | ||
| global tasks | ||
| data = request.get_json() | ||
| if not data or "title" not in data or "description" not in data: |
Collaborator
There was a problem hiding this comment.
duplication. i suggest an function for the "if"
| global tasks | ||
| data = request.get_json() | ||
| if not data or "title" not in data or "description" not in data: | ||
| return jsonify({"error": "Bad Request, data must include 'name' and 'age'"}), 400 |
Collaborator
There was a problem hiding this comment.
checking name and age? this message is from another project :)
| global tasks | ||
| if task_id in tasks: | ||
| if tasks[task_id]["completed"] is True: | ||
| del tasks[task_id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.